
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:fzcgx_app/common/adapter_utils.dart';

import 'package:fzcgx_app/common/assets_utils.dart';


import 'package:fzcgx_app/ui/tabbar_page.dart';
import 'package:nav_router/nav_router.dart';




class GuidePage extends StatefulWidget {
  @override
  _GuidePageState createState() => _GuidePageState();
}

class _GuidePageState extends State<GuidePage> {
  PageController _pageController = PageController();
  // ignore: unused_field
  int _pageIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Container(
          width: AdapterUtils.screenWidth(),
          height: AdapterUtils.screenHeight(),
          child: Stack(
            children: <Widget>[
              _buildPageView(),
              Container(
                alignment: Alignment.bottomCenter,
                child:  Container(
                    width: AdapterUtils.getWidth(132),
                    height: AdapterUtils.getHeight(17),
                    margin: EdgeInsets.only(bottom: AdapterUtils.getHeight(37)),
                    decoration: BoxDecoration(
                        color: Color(0xffF0F0F0),
                        borderRadius: BorderRadius.all(Radius.circular(9))),
                    child: AnimatedContainer(
                      duration: Duration(seconds: 1),
                      curve: Curves.bounceOut,
                      margin: _pageIndex == 0
                          ? EdgeInsets.only(right: 88)
                          : _pageIndex == 1
                              ? EdgeInsets.symmetric(
                                  horizontal: AdapterUtils.getWidth(44))
                              : _pageIndex == 2
                                  ? EdgeInsets.only(left: 88)
                                  : EdgeInsets.only(),
                      height: AdapterUtils.getHeight(17),
                      decoration: BoxDecoration(
                          color: Color(0xff15A1FF),
                          borderRadius: BorderRadius.all(Radius.circular(9))),
                    ),
                  ),
                ),
              
            ],
          )),
    );
  }

  Widget _buildPageView() {
    return PageView(
      controller: _pageController,
      onPageChanged: (pageIndex) {
        if (mounted) {
          setState(() {
            _pageIndex = pageIndex;
            print(_pageController.page);
            print(pageIndex);
          });
        }
      },
      children: <Widget>[
       Container(
         child:  Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            Image.asset(
              AssetsUtils.getAssetsImagesPath('guide_1.png'),
              width: AdapterUtils.getWidth(174),
              height: AdapterUtils.getHeight(232),
              fit: BoxFit.cover,
            ),
             SizedBox(height: AdapterUtils.getHeight(96)),
            RichText(
              text: TextSpan(children: <InlineSpan>[
                TextSpan(
                    text: '找工作：',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(20),
                      color: Color(0xff1D273C),
                      fontWeight: FontWeight.bold,
                    )),
                TextSpan(
                    text: '机会多、速度快',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(17),
                      color: Color(0xff1D273C),
                      fontWeight: FontWeight.w500,
                    )),
              ]),
            ),
             SizedBox(height: AdapterUtils.getHeight(130)),
          ],
        ),
       ),
       Container(
         child:  Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            Image.asset(
              AssetsUtils.getAssetsImagesPath('guide_2.png'),
              width: AdapterUtils.getWidth(174),
              height: AdapterUtils.getHeight(232),
              fit: BoxFit.cover,
            ),
            SizedBox(height: AdapterUtils.getHeight(96)),
            RichText(
              text: TextSpan(children: <InlineSpan>[
                TextSpan(
                    text: '找工厂：',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(20),
                      color: Color(0xff1D273C),
                      fontWeight: FontWeight.bold,
                    )),
                TextSpan(
                    text: '工厂多、速度快、质量高',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(17),
                      color: Color(0xff1D273C),
                      fontWeight: FontWeight.w500,
                    )),
              ]),
            ),
            SizedBox(height: AdapterUtils.getHeight(130)),
          ],
        ),
       ),
        Container(
          child: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            Image.asset(
              AssetsUtils.getAssetsImagesPath('guide_3.png'),
              width: AdapterUtils.getWidth(174),
              height: AdapterUtils.getHeight(232),
              fit: BoxFit.cover,
            ),
            SizedBox(height: AdapterUtils.getHeight(96)),
            RichText(
              text: TextSpan(children: <InlineSpan>[
                TextSpan(
                    text: '找客户：',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(20),
                      color: Color(0xff1D273C),
                      fontWeight: FontWeight.bold,
                    )),
                TextSpan(
                    text: '订单多、订单大',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(17),
                      color: Color(0xff1D273C),
                      fontWeight: FontWeight.w500,
                    )),
              ]),
            ),
            SizedBox(height: AdapterUtils.getHeight(40)),
            Container(
              width: AdapterUtils.getWidth(130),
              height: AdapterUtils.getHeight(40),
              child:  FlatButton(
                onPressed: () {
                SpUtil.putBool('notShowGuide', true);
                  
                 pushAndRemoveUntil(TabbarPage());
                 
                },
                shape: StadiumBorder(),
                color: Color(0xff15A1FF),
                child: Text(
                  '立刻体验',
                  style: TextStyle(
                      fontSize: AdapterUtils.getSp(15),
                      fontWeight: FontWeight.bold,
                      color: Colors.white),
                )),
            ),
            SizedBox(height: AdapterUtils.getHeight(94)),
          ],
        ),
        )
      ],
    );
  }
}
